/**
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"6754CD68-0687-4BE2-9FCD-64D8286E8690"}
 */
function btn_aceptar(event) {
	
	databaseManager.saveData();
	var win = controller.getWindow();
	win.destroy();
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"4DA0E2BA-3803-4C14-9094-FDBFBDFE3F71"}
 */
function btn_cancelar(event) {
	
	databaseManager.revertEditedRecords();
	var win = controller.getWindow();
	win.destroy();
}

/**
 * @param {JSEvent} event
 * @param {String} frm
 *
 * @properties={typeid:24,uuid:"F42DC6A5-B0ED-49EC-B172-36D0766F1F15"}
 */
function btn_volver(event, frm) {
	
	forms.Inicio.elements.tab_mostrar.removeAllTabs();
	forms.Inicio.elements.tab_mostrar.addTab(forms.CLIENTES);
}

/**
 * @param {String} frm
 * @param {JSEvent} event
 *
 * @properties={typeid:24,uuid:"8BCAD270-5EE2-428F-83CB-FAE73AF3F4B1"}
 */
function btn_baja(event, frm) {
	var success = plugins.dialogs.showWarningDialog("Eliminar Registro","¿Está seguro de querer eliminar este registro?","Aceptar", "Candelar");
	if (success == "Aceptar"){
		databaseManager.revertEditedRecords();
		foundset.deleteRecord(foundset.getSelectedRecord());
		forms.Inicio.elements.tab_mostrar.removeAllTabs();
		forms.Inicio.elements.tab_mostrar.addTab(forms[frm]);
	}else{
		return;
	}
}

/**
 * @param {JSEvent} event
 *
 * @properties={typeid:24,uuid:"54F66DF6-8351-4CF9-8D1F-47032AB58657"}
 */
function doEdit(event){
	
	elements.bnt_aceptar.visible = true;
	elements.btn_cancelar.visible = true;
	elements.btn_baja.visible = false;
	elements.btn_volver.visible = false;
}

/**
 * @param {JSEvent} event
 *
 * @properties={typeid:24,uuid:"C38CC66D-9FA2-4F50-B32F-5EA8C4A5E7B4"}
 */
function hide_btn_reset_fields(event){
	
	elements.bnt_aceptar.visible = false;
	elements.btn_cancelar.visible = false;
	elements.btn_baja.visible = true;
	elements.btn_volver.visible = true;
}
